<?php
echo $this->load->view ( 'header' );
?>
<!--头部开始-->
<div>
	<ul class="breadcrumb">
		<li><a href="<?php echo site_url('success'); ?>"><?php echo lang('success_list'); ?></a><span
			class="divider">/</span></li>
		<li><a
			href="<?php echo site_url($this -> config -> item('admin_folder').'success/form');?>"><?php echo $title; ?></a></li>
	</ul>
</div>
<!--头部结束-->
<?php

if ($this->session->flashdata ( 'message' )) {
	$message = $this->session->flashdata ( 'message' );
}

if ($this->session->flashdata ( 'error' )) {
	$error = $this->session->flashdata ( 'error' );
}

if (function_exists ( 'validation_errors' ) && validation_errors () != '') {
	$error = validation_errors ();
}
?>
		
		<?php if (!empty($message)): ?>
<div class="alert alert-info">
	<a class="close" data-dismiss="alert">×</a>
			<?php echo $message; ?>
		</div>
<?php endif; ?>
						<?php if (!empty($error)): ?>
<div class="alert alert-error">
	<a class="close" data-dismiss="alert">×</a>
			<?php echo $error; ?>
		</div>
<?php endif; ?>

<!--角色开始-->

<div class="row-fluid sortable">
	<div class="box span12">
		<div class="box-header well">
			<h2>
				<i class="icon-edit"></i> <?php echo $title; ?></h2>
			<div class="box-icon">
				<a href="#" class="btn btn-minimize btn-round"><i
					class="icon-chevron-up"></i></a> <a href="#"
					class="btn btn-close btn-round"><i class="icon-remove"></i></a>
			</div>
		</div>
		<div class="box-content">
							<?php
							
							$attributes = array (
									'class' => 'form-horizontal',
									'id' => 'success_form' 
							);
							echo form_open ( $this->config->item ( 'admin_folder' ) . 'success/form/' . $id, $attributes );
							?>
						  <fieldset>
				<legend><?php echo lang('hint'); ?></legend>
				
				<div class="control-group">
					<label class="control-label" for="name"><?php echo lang('success_path'); ?></label>
					<div class="controls">
<div class="fileupload fileupload-new" data-provides="fileupload">
  <div class="input-append" style="border: 1px solid #cccccc;">
    <div class="uneditable-input span3"><i class="icon-file fileupload-exists"></i> <span class="fileupload-preview"><?php echo $name; ?></span></div><span class="btn btn-file"><span class="fileupload-new">选择文件</span><span class="fileupload-exists">替换</span><input type="file"/></span><a href="#" class="btn fileupload-exists" data-dismiss="fileupload">移除</a>
<?php
$data = array('id' => 'name', 'name' => 'name', 'value' => set_value('name', $name),'style'=>'display:none');
echo form_input($data);
?>
<?php
$data = array('id' => 'path', 'name' => 'path', 'value' => set_value('path', $path),'style'=>'display:none');
echo form_input($data);
?>
  </div>
  <span class="help-inline"><i class="icon-star"
							title="<?php echo lang('data_required'); ?>"></i><?php echo lang('success_path_span'); ?></span>
</div>
													</div>
				</div>
				 <div class="control-group">
                                  <label class="control-label" for="title_cn">中文标题</label>
                                  <div class="controls">
                                      <?php
                                      $data = array (
                                          'id' => 'title_cn',
                                          'name' => 'title_cn',
                                          'value' => set_value ( 'title_cn', $title_cn )
                                      );
                                      echo form_input ( $data );
                                      ?>
                                      <span class="help-inline">中文标题</span>
                                  </div>
                              </div>
                               <div class="control-group">
                                  <label class="control-label" for="title_en">英文标题</label>
                                  <div class="controls">
                                      <?php
                                      $data = array (
                                          'id' => 'title_en',
                                          'name' => 'title_en',
                                          'value' => set_value ( 'title_en', $title_en)
                                      );
                                      echo form_input ( $data );
                                      ?>
                                      <span class="help-inline">英文标题</span>
                                  </div>
                              </div>
				<div class="control-group">
                                  <label class="control-label" for="remark"><?php echo lang('success_introduce_en'); ?></label>
                                  <div class="controls">

                                      <?php
                                      $data = array('id' => 'introduce_en', 'name' => 'introduce_en', 'value' => set_value('introduce_en', $introduce_en));
                                      echo form_textarea($data);
                                      ?>
                                      <div style="clear:both"></div>
                                      <span class="help-inline"><i class="icon-star"
                                                                   title="<?php echo lang('data_required'); ?>"></i><?php echo lang('success_introduce_en_span'); ?></span>
                                  </div>
                <div class="control-group">
                                  <label class="control-label" for="remark"><?php echo lang('success_introduce_cn'); ?></label>
                                  <div class="controls">

                                      <?php
                                      $data = array('id' => 'introduce_cn', 'name' => 'introduce_cn', 'value' => set_value('introduce_cn', $introduce_cn));
                                      echo form_textarea($data);
                                      ?>
                                      <div style="clear:both"></div>
                                      <span class="help-inline"><i class="icon-star"
                                                                   title="<?php echo lang('data_required'); ?>"></i><?php echo lang('success_introduce_cn_span'); ?></span>
                                  </div>


				<div class="form-actions">
					<button type="submit" class="btn btn-primary"><?php echo lang('button_save'); ?></button>
				</div>
			</fieldset>
			</form>
		</div>
	</div>
	<!--/box span12-->
</div>
<!--/row-->
<!--角色结束-->
<?php
echo $this->load->view ( 'footer' );
?>
<!-- Latest compiled and minified CSS -->
<!-- Latest compiled and minified JavaScript -->
<script src="http://gosspublic.alicdn.com/aliyun-oss-sdk-4.4.4.min.js"></script>
<script type="text/javascript"
	src="<?php echo SITE_ADMIN_JS; ?>/lib_ajax_cate.js"></script>
<script type="text/javascript"
	src="<?php echo SITE_ADMIN_JS; ?>/jasny-bootstrap.min.js"></script>
<script type="text/javascript">
    var client = new OSS.Wrapper({
      region: 'oss-cn-shanghai',
      accessKeyId: 'uwOioOkTu5cU73Xq',
      accessKeySecret: 'K85pNoERpzlyWvnSak7SfnBgXzy5Qe',
      bucket: 'mengzx'
    });
    $(".fileupload").on("change",function (e) {
      var file = e.target.files[0];
      var storeAs = "img/"+ new Date().getTime();
      console.log(file.name + ' => ' + storeAs);
      $("#name").val(file.name);
      $("#path").val("http://mengzx.oss-cn-shanghai.aliyuncs.com/"+storeAs);
      client.multipartUpload(storeAs, file).then(function (result) {
        console.log(result);
      }).catch(function (err) {
        console.log(err);
      });
    });
    // document.getElementById('file').addEventListener('change', function (e) {
    //   var file = e.target.files[0];
    //   var storeAs = 'upload-file';
    //   console.log(file.name + ' => ' + storeAs);
    //   client.multipartUpload(storeAs, file).then(function (result) {
    //     console.log(result);
    //   }).catch(function (err) {
    //     console.log(err);
    //   });
    // });
  </script>
 </body>
</html>


